<template>
  <div>
    <!--搜索查询-->
    <el-row>
      <el-col :span="4">
        <el-input 
        v-model="searchForm.member_id" 
        size="mini" 
        placeholder="请输用户id"></el-input>
      </el-col>
      <el-col :span="3">

      </el-col>
      <el-col :span="3">
        <el-button 
        type="primary" 
        size="mini" 
        @click="search()" 
        icon="el-icon-search"
        v-has="'role:search'"
        >搜索</el-button>
      </el-col>
    <el-col :span="3"
        ><el-button
          type="primary"
          size="mini"
          @click="flush()"
          icon="el-icon-refresh"
          v-has="'role:flush'"
          >刷新</el-button>
        </el-col>
      <el-col :span="3">
        
      </el-col>
    </el-row>

    <el-row>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="userName" label="用户名" width="180" align="center">
        </el-table-column>
        <el-table-column prop="typeName" label="车辆名" width="180" align="center">
        </el-table-column>
        <el-table-column prop="content" label="评价内容" width="280" align="center"> </el-table-column>
        <el-table-column prop="useNum" label="评论点赞数量" width="180" align="center"> </el-table-column>
        <el-table-column prop="addtime" label="添加时间" width="280" align="center"> </el-table-column>
      </el-table>
    </el-row>
    <el-row>
      <!--分页插件-->
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
        :page-sizes="[2, 3, 5, 10, 20]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </el-row>

  </div>
</template>

  <script>
export default {
  data() {
    return {
      tableData: [],
      currentPage: 1, //页码 第几页
      pageSize: 5, //每页显示数量
      total: 100, //总条数
      form: {},//form表单对象
      searchForm: {
        member_id: ''
      },//搜索form表单
    };
  },
  created() {
    this.loadData();
  },
  //所有函数
  methods: {
    //加载数据
    loadData() {
      var _this = this;
      //复制 axios官网代码
      // var token  = localStorage.getItem("token");
      this.$http
        .post("/carComment/selectAllAndMemberAndCarConfig", {
          pageNo: this.currentPage,
          pageSize: this.pageSize,
          data: {
            memberId: this.searchForm.member_id,
          }
        })
        .then(function (response) {
          if (response.data.code == 200) {
            _this.tableData = response.data.data.records;
            _this.total = response.data.data.total;
          }
        })
        .catch(function (error) {
          console.log(error);
          _this.$message.error("你错了。。。");
        });
    },
    //处理每页数量发生变化
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      //让每页数量发生变化
      this.pageSize = val;
      //重载数据
      this.loadData();
    },
    //处理当前页变化
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      //让每页数量发生变化
      this.currentPage = val;
      //重载数据
      this.loadData();
    },
    //查询
    search() {
      this.loadData();
    },
    //刷新
    flush() {
    location.reload();
    },
  },
};
</script>
  <style>
  </style>